"""
@Author：WangYuXiang
@E-mile：Hill@3io.cc
@CreateTime：2021/6/21 10:52
@DependencyLibrary：无
@MainFunction：无
@FileDoc： 
    models.py.py
    文件说明
@ChangeHistory:
    datetime action why
    example:
    2021/6/21 10:52 change 'Fix bug'
        
"""
from enum import IntEnum

from tortoise import fields

from common.utils.models import BaseModel


class SchoolModel(BaseModel):
    name = fields.CharField(32, unique=True, description='学校名称')
    note = fields.TextField(description='学校描述')

    president = fields.ForeignKeyField(model_name='auth.UserModel', related_name='school')


class ClassModel(BaseModel):
    name = fields.CharField(32, unique=True, description='班级名称')

    class_man = fields.ForeignKeyField(model_name='auth.UserModel', related_name='class')
    school: fields.ForeignKeyRelation[SchoolModel] = fields.ForeignKeyField(model_name='school.SchoolModel', related_name='class')


class QuestionType(IntEnum):
    Woman = 0
    Man = 1


class StudentModel(BaseModel):
    name = fields.CharField(32, unique=True, description='学生名称')
    gender = fields.IntEnumField(QuestionType, description='性别')
    age = fields.IntField(description='年龄')
    phone = fields.CharField(11, description='联系电话')
    nation = fields.CharField(32, description='民族')
    in_class = fields.ForeignKeyField(model_name='school.ClassModel', related_name='student')
